package com.wnhz.work.yz.fragment.bathroomdetails;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.wnhz.work.yz.R;

/**
 * A simple {@link Fragment} subclass.
 * ---安装说明
 */
public class InstallExplainFragment extends Fragment implements View.OnClickListener {
    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_install_explain, container, false);

        return view;
    }

    private void initData() {
        WebSettings settings = webview.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUseWideViewPort(false);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小

        if (webview != null) {
            webview.setWebViewClient(new WebViewClient() {
                @Override
                public void onPageFinished(WebView view, String url) {
                    //   handler.sendEmptyMessage(1);
                    super.onPageFinished(view, url);
                }
            });
//            webview.getSettings().setJavaScriptEnabled(true);
            webview.loadUrl(installationStr);
        }
    }

    private WebView webview;
    private String installationStr = "";

    private void initView() {
        webview = (WebView) view.findViewById(R.id.webview);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
        }
    }

    public void setData(String data) {
        this.installationStr = data;
        initView();
        initData();
    }
}
